<html>
<head>
    <title>compare</title>
    <script src='https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js'></script>
</head>
    <body>
        <div>
            <textarea id="content" name="content" id="" cols="30" rows="10">这是一个测试文本</textarea>
            <textarea id="new_content" name="new_content" id="" cols="30" rows="10">这是一个文本,来源未知</textarea>
        </div>


        <div>
            <button id="compare">比较</button>
        </div>

        <div id="result"></div>

        <script>
             var ajax = function(url,data,fb) {
                $.ajax({url: url,type: "post",data: data,
                    success: function(res){
                        fb(res);
                    },
                    error:function(XMLHttpRequest, textStatus, errorThrown){
                        msg('请求失败');
                    },
                });
            }

            function compare() {
                var content = $('#content').val()
                var new_content = $('#new_content').val()
                ajax("/html",{content:content,new_content:new_content},function(res){
                    if(res.code==0) {
                        $('#result').html(res.data)
                    }
                })
            }

            function compare1() {
                var content = $('#content').val()
                var new_content = $('#new_content').val()
                ajax("/",{content:content,new_content:new_content},function(res){
                    if(res.code==0) {
                        res.data.forEach((elem, index) => {
                         console.log(elem);
                        });
                    }
                })
            }
            $('#compare').click(function(){
                compare()
            })
        </script>
    </body>
</html>